using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerDashState : PlayerState
{
    public PlayerDashState(Player _player, PlayerStateMachine _stateMachine, string _animBoolName) : base(_player, _stateMachine, _animBoolName)
    {
    }

    public override void Enter()
    {
        base.Enter();

        SkillManager.instance.clone.CreateClone(player.transform);
        stateTimer = player.DashDuration;
    }

    public override void Exit()
    {
        player.SetVelocity(player.DashExitSpeed * player.facingDir, rb.velocity.y);
        base.Exit();
    }

    public override void Update()
    {
        base.Update();
        player.SetVelocity(player.DashSpeed * player.DashDir, 0);
        if(player.IsWallDetected())
        {
            stateMachine.ChangeState(player.wallSlideState); 
        }
        if(stateTimer < 0) {
            stateMachine.ChangeState(player.idleState);
        }
    }
}
